#ifndef IMAGELOADER_H
#define IMAGELOADER_H

#pragma once

#include "../ToolkitLayer.h"

/**
 * This class loads an image from a file and keeps the image data until another
 * file is loaded. It uses the DevIL library (previously known as OpenIL) to
 * load the files (http://openil.sourceforge.net/).
 *
 * @author Fabricio Anastacio - fabriciocfa@yahoo.com
 * @since August 7, 2007
 */
class TOOLKITLAYER_API ImageLoader
{
	// Attributes
private:
	/** The OpenGL format of the currently loaded image, */
	int glImageFormat;


	// Methods
public:
	/**
	 * Constructs a image loader.
	 */
	ImageLoader(void);
	/**
	 * Destroys this image loader.
	 */
	~ImageLoader(void);


	/**
	 * Loads an image from the given file.
	 *
	 * @param imageFile the path to the image file to be loaded.
	 * @throw std::invalid_argument if the given image file cannot be loaded.
	 */
	void loadImage(const char* fileName);

	/**
	 * Returns true if the loaded image has an alpha channel.
	 *
	 * @return true if the loaded image has an alpha channel, false otherwise.
	 */
	bool hasAlphaChannel();


	// ACCESSOR METHODS
	/**
	 * Returns the OpenGL format of the loaded image.
	 *
	 * @return the OpenGL format of the loaded image.
	 */
	int getGLImageFormat();
	/**
	 * Returns the loaded image width.
	 *
	 * @return the loaded image width.
	 */
	unsigned int getImageWidth();
	/**
	 * Returns the loaded image height.
	 *
	 * @return the loaded image height.
	 */
	unsigned int getImageHeight();
	/**
	 * Returns the loaded image array of pixels.
	 *
	 * @return the loaded image array of pixels.
	 */
	unsigned char* getImage();
};

#endif // IMAGELOADER_H
